package musique;

	public class Guitare
	{
	    // instance variables - replace the example below with your own
	    private boolean accorde;
	    private int nbCCassees;
	    private Musicien proprietaire;
	    private String brand;
	   
	    public Guitare(){
	    	this.accorde = false;
	    	this.nbCCassees = 0;
	    	this.proprietaire = null;
	    }
	    
	    public Guitare(Musicien proprietaire){
	    	this.accorde = false;
	    	this.nbCCassees = 0;
	    	this.proprietaire = proprietaire;
	    }
	    
	    public Guitare(boolean estAccorde, int nbCordesCassees, Musicien proprietaire){
	    	
	    	
	    	if (this.nbCCassees > 0 || this.nbCCassees <= 6)
	    	{
	    		this.accorde = false;
	    	}
	    	else
	    	{
	    		this.accorde = estAccorde;
	    	}
	    	
	    	if (this.nbCCassees < 0 || this.nbCCassees > 6)
	    		{this.nbCCassees = nbCordesCassees;}
	    	else 
	    		{this.nbCCassees = 0;}
	    	
	    	this.proprietaire = proprietaire;
	    	this.proprietaire.ajouterGuitare(this);
	    }
	    
	    public Guitare(boolean estAccorde, int nbCordesCassees){
	    	
	    	
	    	if (this.nbCCassees > 0 || this.nbCCassees <= 6)
	    	{
	    		this.accorde = false;
	    	}
	    	else
	    	{
	    		this.accorde = estAccorde;
	    	}
	    	
	    	if (this.nbCCassees < 0 || this.nbCCassees > 6)
	    		{this.nbCCassees = nbCordesCassees;}
	    	else 
	    		{this.nbCCassees = 0;}
	    	
	    	this.proprietaire = null;
	    }
	    
	    
		public void setProprietaire(Musicien proprietaire) {
			
			if (this.proprietaire != null) 
				{this.proprietaire.retirerGuitare(this);}
			this.proprietaire = proprietaire;
			//this.proprietaire.ajouterGuitare(this);
			
		}

		public Musicien getProprietaire() {
			return proprietaire;
		}   
	    
	    public boolean getAccorde()
	    {
	        return this.accorde;
	    }
	    
	    public void setAccorde(boolean estAccorde)
	    {
	    	if (!accordagePossible(this.nbCCassees))
    		{ 	estAccorde = false;}
	        this.accorde = estAccorde;
	    }
	   
	    public int getNbCordesCassees()
	    {
	        return this.nbCCassees;
	    }
	   

	   
	    public void setNbCordesCassees(int nbCordesCassees)
	    {
	    	if (nbCordesCassees <= 6)
	    		{
	    		this.nbCCassees = nbCordesCassees;
	    		if (!accordagePossible(nbCordesCassees))
	    			{
	    			this.nbCCassees = nbCordesCassees;
	    			this.accorde = false;
	    			}
	    		}
	    }
	   
	   
	    public boolean guitareFonctionelle()
	    {
	        if(accorde == true && nbCCassees == 0)
	        	return true;
	        else
	        	return false;
	    }

	    public boolean accordagePossible(int nbCCassees)
	    {
	    	if (nbCCassees < 6)
	    		{return true;}
	    	else
	    		return false;
	    }
	    
	    public String toString(){
	    	return  ""+this.getNbCordesCassees();
		}

}
